package com.kakarote.examine.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.kakarote.core.servlet.BaseServiceImpl;
import com.kakarote.examine.entity.PO.ExamineAdvancedConfigLimitTime;
import com.kakarote.examine.entity.PO.ExamineRecord;
import com.kakarote.examine.mapper.ExamineAdvancedConfigLimitTimeMapper;
import com.kakarote.examine.service.IExamineAdvancedConfigLimitTimeService;
import com.kakarote.examine.service.IExamineRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 审批高级配置-节点限时处理配置表 服务实现类
 * </p>
 *
 * @author zyl
 * @since 2022-08-30
 */
@Service
public class ExamineAdvancedConfigLimitTimeServiceImpl extends BaseServiceImpl<ExamineAdvancedConfigLimitTimeMapper, ExamineAdvancedConfigLimitTime> implements IExamineAdvancedConfigLimitTimeService {

    @Autowired
    private IExamineRecordService examineRecordService;

    /**
     * 通过recordId查询审批高级配置-节点限时处理配置表
     *
     * @param recordId 审批记录ID
     * @return data
     */
    @Override
    public ExamineAdvancedConfigLimitTime queryConfigByRecordId(Long recordId) {
        ExamineRecord examineRecord = examineRecordService.getById(recordId);
        if (BeanUtil.isEmpty(examineRecord)) {
            return null;
        }
        return lambdaQuery().eq(ExamineAdvancedConfigLimitTime::getExamineId, examineRecord.getExamineId()).one();
    }
}
